package org.sqldroid;

import java.sql.Connection;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.util.Properties;

public class SQLDroidDriver implements java.sql.Driver {

	// TODO(uwe): Allow jdbc:sqlite: url as well
	public static String sqldroidPrefix = "jdbc:sqldroid:";

	static {
		try {
			java.sql.DriverManager.registerDriver(new SQLDroidDriver());
		} catch (final Exception e) {
			e.printStackTrace();
		}

	}

	public boolean acceptsURL(final String url) throws SQLException {

		if (url.startsWith(sqldroidPrefix)) {
			return true;
		}

		return false;
	}

	public Connection connect(final String url, final Properties info) throws SQLException {

		return new SqldroidConnection(url, info);
	}

	public int getMajorVersion() {
		return 0;
	}

	public int getMinorVersion() {
		return 2;
	}

	public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) throws SQLException {
		System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line "
				+ DebugPrinter.getLineNumber());
		return null;
	}

	public boolean jdbcCompliant() {
		return false;
	}

}
